package game.level;

import engine.Engine;
import engine.MADGL;
import engine.game.Game;
import engine.game.Level;

import game.gui.*;
import game.view.LevelCamera;

public class TestLevel extends Level{

	private static final long serialVersionUID = 1L;

//	--> not saving the GUI 
//	private transient GUIManager gui ;
// 	--> saving the GUI 
	private GUIManager gui ; 
	private EntityManager entities ;
	private LevelObjectManager levelObjects ; 
	private ItemManager items ; 
	
	private LevelCamera camera ; 
	
	public TestLevel(Game g){
		super(g, 16384, Engine.HEIGHT);
		init();
	}
	
	public GUIManager getGUI(){
		return this.gui ; 
	}
	
	public EntityManager getEntities(){
		return this.entities; 
	}
	
	public LevelObjectManager getLevelObjects(){
		return this.levelObjects; 
	}
	
	public ItemManager getItems(){
		return this.items; 
	}

	@Override
	public void init() {
		super.init();
		camera = new LevelCamera(0, 0, this);
		entities = new EntityManager(gameObjects, this); 
		levelObjects = new LevelObjectManager(gameObjects, this);
		items = new ItemManager(gameObjects, this);
		gui = new GUIManager(null, this, this.entities.getPlayer());
	}
	
	public void initGUI(){
	}

	@Override
	public void update() {
		levelObjects.update();
		entities.update();  
		items.update(); 
		gui.update();
		camera.centerCameraToObject(entities.getPlayer());
	}

	@Override
	public void render() {
		MADGL.startMatrix();
			camera.render();
			levelObjects.render(); 
			entities.render(); 
			items.render(); 
		MADGL.endMatrix();
		gui.render(); 
	}

	@Override
	public void getInput() {
		entities.getInput();
		gui.getInput();
	}


}
